package com.carl.lambda.simpleLambda.demand00;

import org.junit.Test;

public class LambdaTest {

    //需求:对一个数进行计算
    
    @Test
    public void add(){
        Integer result = operation(100,90, Integer::sum);
        System.out.println(result);
        System.out.println("-------------------------------");

        Integer result2 = operation(20,9,Integer::compare);
        System.out.println(result2);
        System.out.println("-------------------------------");

        Integer result3 = operation(20,9,(x,y) -> (x - y));
        System.out.println(result3);



    }

    //具体什么运算不用指定
    public Integer operation(Integer num,Integer num2,MyFunction<Integer,Integer> op){
        return op.getValue(num,num2);
    }

}
